cmake_minimum_required(VERSION 3.8)
project(rviz_tools_pkg)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

find_package(rclcpp REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_default_plugins REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(pluginlib REQUIRED)
# 自定义功能包
find_package(nav_msg_pkg REQUIRED)
find_package(rviz_util_pkg REQUIRED)
find_package(agv_util REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

# Qt5 MOC处理
set(CMAKE_AUTOMOC ON)
qt5_wrap_cpp(MOC_FILES
  include/rviz_tools_pkg/add_point_tool.hpp
)

# 包含头文件目录
include_directories(include)
# 生成库  库的定义为： add_point_tool
add_library(add_point_tool SHARED
  src/add_point_tool.cpp
  ${MOC_FILES}
)
target_include_directories(add_point_tool PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)
ament_target_dependencies(add_point_tool
    "rclcpp"
    "rviz_common"
    "rviz_default_plugins"
    "geometry_msgs"
    "pluginlib"
)
####################################
# 编译节点
add_executable(edit_point src/edit_point.cpp)
ament_target_dependencies(edit_point 
  "rclcpp"
  "geometry_msgs"
  "agv_util"
  "rviz_util_pkg"
  "nav_msg_pkg")

# 安装规则
install(TARGETS
  edit_point
  DESTINATION lib/${PROJECT_NAME})
########################################
# 安装配置
install(TARGETS add_point_tool
        EXPORT export_rviz_tools_pkg
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION bin
)

install(DIRECTORY include/
    DESTINATION include
)

install(FILES plugins_description.xml
    DESTINATION share/${PROJECT_NAME}
)
install(
    DIRECTORY
    launch
    rviz
    DESTINATION
    share/${PROJECT_NAME}
)

# 导出插件描述文件
pluginlib_export_plugin_description_file(rviz_common plugins_description.xml)


ament_package()
